package ru.vsu.amm.scenes.extensions;

import org.jzy3d.chart.controllers.mouse.camera.CameraMouseController;

import java.awt.event.MouseWheelEvent;

/**
 * User: Saksonov Andrey <saksonov@amm.vsu.ru>
 * Date: 19.12.12
 * Time: 16:23
 */
public class ZoomCameraMouseController extends CameraMouseController {

    private String zoomAxis = "Z";

    @Override
    public void mouseWheelMoved(MouseWheelEvent e) {
        if (threadController != null)
            threadController.stop();

        float factor = 1 + (e.getWheelRotation() / 10.0f);
        if (zoomAxis.equalsIgnoreCase("Z")) {
            zoomZ(factor);
        } else if (zoomAxis.equalsIgnoreCase("X")) {
            zoomX(factor);
        } else if (zoomAxis.equalsIgnoreCase("Y")) {
            zoomY(factor);
        }
    }

    public void setZoomAxis(String axis) {
        if (axis.equalsIgnoreCase("Z")) {
            zoomAxis = "Z";
            return;
        }
        if (axis.equalsIgnoreCase("X")) {
            zoomAxis = "X";
            return;
        }
        if (axis.equalsIgnoreCase("Y")) {
            zoomAxis = "Y";
            return;
        }
        throw new IllegalArgumentException("Неверный параметр: " + axis + ". Ожидалось: [\"X\", \"Y\", \"Z\"]");
    }
}